﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using IMModel.Domain;

namespace DataAccessLayer
{
    public static class DepartmentName
    {
        private static Regex checkTemplate = new Regex("[\\{0}\\}]{1}");

        #region Перегрузки GetFullName
        public static string GetFullName(string Type, string Name)
        {
            if (checkTemplate.Match(Name).Success)
                return ucfirst(string.Format(Name, Type));
            else
                return Name;
        }

        public static string GetFullName(Department department, DepartmentType departmentType)
        {
            return GetFullName(departmentType.Name, department.Name);
        }

        public static string GetFullName(Department department)
        {
            return GetFullName(department.DepartmentType.Name, department.Name);
        }
        #endregion

        public static string ucfirst(string str)
        {
            if (string.IsNullOrEmpty(str))
                return str;
            else
            {
                string lowerString = str.ToLower();
                return char.ToUpper(lowerString[0]) + lowerString.Substring(1);
            }
        }
    }
}